(function() {
	var app = angular.module("angularApp", []);

	function to2(num) {
		return ((100+num)+"").substr(1);

	}
	function formate(date){
		var week=['日','一','二','三','四','五','六'];

		var y=date.getFullYear()+"年";

		var m=date.getMonth()+1+"月";

		var d=date.getDate()+"日";

		var w="星期"+week[date.getDay()];

		var h=date.getHours();

		var mi=date.getMinutes();

		var s=date.getSeconds();
		//+":"+s
		var str=y+m+d+" "+to2(h)+":"+to2(mi)+" "+w;
		return str;
	}

	 app.controller('indexController', function($scope, $rootScope, $http,$interval) {
	 	 var dict = [
	 	 		[10,"已申报"],[11,"预审通过"],[11,"预审驳回"],[20,"已受理"],[30,"在办"],[41,"一般特别程序"],[42,"收费环节"],
			 [50,"补齐补正"],[61,"准予许可办结"],[62,"不予许可办结"],[63,"不予受理办结"],[64,"其它办结"],[71,"邮寄出证"],
		 ];
	 	 var number = 0;
	 	 function query() {
			 $http.get("/api/query",{params:{pageNo:number%10+1,pageSize:35}}).success(datas=>{
				 datas.data.forEach((n,i)=>{
				 	  var arrs = dict.find(m=>m[0]==n.processStatus);
					  n.processName = arrs?arrs[1]:"准予许可办结";
					  n.index = i;
				 })
					$scope.page = datas;
			 })
			 $scope.date = formate(new Date());
		 }
		 query();
		 $("#scrollAuto").newsScroll({
			 "hoverstop": false,
			 "spacetime": 3000,
			 "num": 4
		 });
		 $interval(query,20000);
	 })
})();
